package com.example.travelservlet.love.controller;

import com.example.travelservlet.entity.Label;
import com.example.travelservlet.entity.User;
import com.example.travelservlet.love.service.LoveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author yxj
 * @date 2023/6/13 8:20
 */
@RestController
@RequestMapping("/love")
public class LoveController {
    @Autowired
    private LoveService loveService;

    @GetMapping("findAllLabel")
    public List<Label> findAllLabel() {
        return loveService.findAllLabel();
    }

    @GetMapping("/findById/{labelId}")
    public Label findById(@PathVariable String labelId) {
        Label label = loveService.findLabelById(labelId);
        return label;
    }

    @GetMapping("/findLoves/{userId}")
    public List<String> findFocus(@PathVariable String userId) {
        List<String> labelId = loveService.findLabelId(userId);
        return labelId;
    }

    @GetMapping("/findloveLabelsById/{userId}")
    public List<Label> findloveLabelsById(@PathVariable String userId){
        List<Label> loveLabelsByUserId = loveService.findLoveLabelsByUserId(userId);
        return loveLabelsByUserId;
    }

    @GetMapping("/addLabel/{userId}/{labelId}")
    public Integer addLike(@PathVariable String userId, @PathVariable String labelId){
        Integer integer = loveService.addUserLabel(userId, labelId);
        return integer;
    }
    @GetMapping("/deleteLabels/{userId}/{labelId}")
    public Integer deleteLabels(@PathVariable String userId, @PathVariable String labelId){
        Integer integer = loveService.deleteLabels(userId, labelId);
        return integer;
    }
}
